package com.ljf.dubbo.stub;

import com.ljf.dubbo.TestService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;
import java.util.Scanner;
import java.util.concurrent.ExecutionException;

/**
 * @创建人 lIUJF
 * @创建时间 2019/1/4
 * @描述: 异步调用要在提供者配置 async="true" , 在消费者获取数据通过RpcContext.getContext().getFuture()的future对象
 */
public class StubConsumerClient {
	public static void main(String[] args) throws ExecutionException, InterruptedException{
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-stub-consumer.xml");
		context.start();
		while (true) {
			Scanner scanner = new Scanner(System.in);
			String message = scanner.next();
			//获取接口
			TestService service = (TestService) context.getBean("consumerService");

			//比如有两个表，从2017和2018年查出所有的订单集合，用merger="true"合并查出结果
			String s = service.sendMessage(message, 1);
			System.out.println(s);
		}
	}
}
